//
//  RelatedLinesCell.m
//  ImGuider
//
//  Created by 王鹏宇 on 2017/10/16.
//  Copyright © 2017年 AudioCtrip. All rights reserved.
//

#import "RelatedLinesCell.h"
#import "LinePreDetailVC.h"

@interface RelatedLinesCell ()
@property (nonatomic, strong) LineModel *lineModel;
@end

@implementation RelatedLinesCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    self.listenCountLabel.textColor = kContentColor;
    self.timeLabel.textColor = kContentColor;
    self.tagView.tagViewWidth = self.tagViewWidth;
    
    UITapGestureRecognizer * tapCell = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(goScenicDetailVC)];
    [self.contentView addGestureRecognizer:tapCell];
    self.guiderNameWith.constant = 64;
    if (!ISiPhone5 && !ISiPhone4) {
        self.space.constant = 20;
        self.guiderNameWith.constant = 32;
    }
}

- (void)configDataWintLineModel:(LineModel *)model {
    
    self.lineModel = model;
    
    [self.lineImageView setImageURL:[NSURL URLWithString:model.pictureArray.firstObject] placeholderImage:[UIImage imageNamed:@"placeholder_squ"]];
    self.guiderIconView.headerImageName  = model.guide.headimg;
    self.guiderIconView.vip = model.guide.vip;
    
    self.guiderNameLabel.text = model.guide.realname;
    self.lineNameLabel.text = model.linename;
    self.listenCountLabel.text = [NSString stringWithFormat:@"%@",model.visits];
    self.timeLabel.text = [NSString stringWithFormat:@"%@min",model.timelabel];
    self.tagView.tagsArray = model.tagArray;
    
    [self.starView setScore:model.score.floatValue/10];
    switch (model.transport.integerValue) {
        case 1:
            self.transportImageView.image = [UIImage  imageNamed:@"urbanline_foot_white"];
            break;
        case 2:
            self.transportImageView.image = [UIImage  imageNamed:@"urbanline_bus_white"];
            break;
        case 3:
            self.transportImageView.image = [UIImage  imageNamed:@"urbanline_ship_white"];
            break;
        case 4:
            self.transportImageView.image = [UIImage  imageNamed:@"urbanline_car_white"];
            break;
            
        default:
            self.transportImageView.image = [UIImage  imageNamed:@"urbanline_foot_white"];
            break;
    }
    
}

- (void)goScenicDetailVC {
    
    if (self.superVC && self.lineModel) {
        
        LinePreDetailVC *detailVC = [IGUtil loadViewController:@"LinePreDetailVC" storyboard:@"LineDetail"];
        detailVC.lineid = self.lineModel.lineid;
        
        [AppManager sharedManager].lineid = self.lineModel.lineid;
        
//        self.superVC.NoAnimation = YES;
        [self.superVC.navigationController pushViewController:detailVC animated:YES];
    }
}

@end
